import unittest
from 烤地瓜 import SweetPotato  # 假设待测函数是SweetPotato类的方法

class TestSweetPotatoCooking(unittest.TestCase):
    def setUp(self):
        self.potato = SweetPotato()

    def test_undercooked_potato(self):

        """测试半生不熟状态"""
        self.potato.cook(4)
        self.assertEqual(self.potato.cookedString, "半生不熟")
        self.potato.cook(1)  # 累计5，边界测试
        self.assertEqual(self.potato.cookedString, "烤好了")
    def test_raw_potato(self):
        """测试初始状态和短时间烤制"""
        self.assertEqual(self.potato.cookedString, "生的")
        self.potato.cook(0)
        self.assertEqual(self.potato.cookedString, "生的")
        self.potato.cook(2)
        self.assertEqual(self.potato.cookedString, "生的")
    
    def test_well_cooked_potato(self):
        """测试烤好的状态"""
        self.potato.cook(6)
        self.assertEqual(self.potato.cookedString, "烤好了")
        self.potato.cook(2)  # 累计8，边界测试
        self.assertEqual(self.potato.cookedString, "烤成灰了")
    
    def test_overcooked_potato(self):
        """测试烤焦的状态"""
        self.potato.cook(9)
        self.assertEqual(self.potato.cookedString, "烤成灰了")
        self.potato.cook(1)  # 测试继续烤制
        self.assertEqual(self.potato.cookedString, "烤成灰了")
    
    def test_incremental_cooking(self):
        """测试逐步烤制的状态变化"""
        self.potato.cook(3)
        self.assertEqual(self.potato.cookedString, "生的")
        self.potato.cook(1)  # 累计4
        self.assertEqual(self.potato.cookedString, "半生不熟")
        self.potato.cook(2)  # 累计6
        self.assertEqual(self.potato.cookedString, "烤好了")
        self.potato.cook(3)  # 累计9
        self.assertEqual(self.potato.cookedString, "烤成灰了")

if __name__ == '__main__':
    unittest.main()
